package com.yanfan.point.service.impl;

import java.util.Arrays;
import java.util.List;
import com.yanfan.common.utils.StringUtils;
import com.yanfan.point.domain.IbmsDeviceType;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanfan.point.mapper.IbmsDeviceGroupMapper;
import com.yanfan.point.domain.IbmsDeviceGroup;
import com.yanfan.point.service.IIbmsDeviceGroupService;

/**
 * 设备分组Service业务层处理
 *
 * @author genluo
 * @date 2024-10-10
 */
@Service
public class IbmsDeviceGroupServiceImpl extends ServiceImpl<IbmsDeviceGroupMapper,
        IbmsDeviceGroup> implements IIbmsDeviceGroupService {
    @Autowired
    private IbmsDeviceGroupMapper ibmsDeviceGroupMapper;


    /**
     * 查询设备分组列表
     *
     * @param ibmsDeviceGroup 设备分组
     * @return 设备分组
     */
    @Override
    public List<IbmsDeviceGroup> queryPageList(IbmsDeviceGroup ibmsDeviceGroup) {
        LambdaQueryWrapper<IbmsDeviceGroup> lqw = buildQueryWrapper(ibmsDeviceGroup);
        return ibmsDeviceGroupMapper.selectList(lqw);
        //连表查询可用该方法，在此方法SQL语句上进行扩展
        //return ibmsDeviceGroupMapper.queryPageList(ibmsDeviceGroup);
    }


    /**
    * 分页查询条件
    * @return
    */
    private LambdaQueryWrapper<IbmsDeviceGroup> buildQueryWrapper(IbmsDeviceGroup bo) {
        LambdaQueryWrapper<IbmsDeviceGroup> lqw = Wrappers.lambdaQuery();
        lqw.like(StringUtils.isNotBlank(bo.getGroupName()), IbmsDeviceGroup::getGroupName, bo.getGroupName());
        lqw.eq(StringUtils.isNotBlank(bo.getIsNowProject()), IbmsDeviceGroup::getIsNowProject, bo.getIsNowProject());
        lqw.eq(StringUtils.isNotBlank(bo.getIcon()), IbmsDeviceGroup::getIcon, bo.getIcon());
        return lqw;
    }



}
